package com.manage.api.controller;

import com.manage.common.result.Result;
import com.manage.pojo.dto.CaseFindDTO;
import com.manage.pojo.dto.CaseLawerDTO;
import com.manage.pojo.entity.CaseManage;
import com.manage.pojo.entity.CmCase;
import com.manage.pojo.entity.case_manage.*;
import com.manage.pojo.vo.CaseManageListVO;
import com.manage.pojo.vo.CmCaseWarningVO;
import com.manage.pojo.vo.CmSysUserVO;
import com.manage.pojo.vo.DepositSettlementStatusVO;
import com.manage.service.ICmCaseManageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.bouncycastle.jcajce.provider.asymmetric.ec.IESCipher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 案件Controller
 *
 */
@RestController
@RequestMapping("/caseManagement")
@Tag(name = "案件管理", description = "案件管理接口") // 分类标签
public class CmCaseManageController {
    @Autowired
    private ICmCaseManageService cmCaseManageService;

    /**
     * 查询案件列表
     */
    @PostMapping("/caseManageList")
    @Operation(summary = "案件列表")
    public Result<CaseManageDataInfo> caseManageList(@RequestBody CaseManageParam caseManageParam)
    {
        return Result.success(cmCaseManageService.selectCmCaseManage(caseManageParam));
    }

    /**
     * 移交案件列表
     */
    @GetMapping("/caseTransfer")
    @Operation(summary = "移交案件列表")
    public Result<CaseTransferDto> caseTransfer(@RequestBody CaseTransferParam caseTransferParam){
        return new Result().success(cmCaseManageService.caseTransfer(caseTransferParam));
    }

    /**
     * 委托记录列表
     */
    @GetMapping("/caseEntrustedRecord")
    @Operation(summary = "委托记录")
    public Result<CaseEntrustedRecordDto> caseEntrustedRecord(@RequestBody CaseEntrustedRecordParam caseEntrustedRecordParam){
        return new Result().success(cmCaseManageService.caseEntrustedRecord(caseEntrustedRecordParam));
    }

    /**
     * 分配案件列表
     */
    @PostMapping("/caseAssign")
    @Operation(summary = "分配案件列表")
    public Result<CaseAssignDto> caseAssign(@RequestBody CaseAssignParam caseAssignParam){
        return new Result().success(cmCaseManageService.caseAssign(caseAssignParam));
    }

    /**
     * 结算结果
     */
    @GetMapping("/caseResult")
    @Operation(summary = "结算结果")
    public Result<CaseResultDto> caseResult(@RequestBody CaseResultParam  caseResultParam){
        return new Result().success(cmCaseManageService.caseResult(caseResultParam));
    }

    /**
     * 查询委托对应的所有案件
     */
    @GetMapping("/caseEntrustedList")
    @Operation(summary = "查询委托对应的所有案件")
    public Result<List<CmCase>>  caseEntrustedList(@RequestBody CaseEntrustedParam caseEntrustedParam){
        return  new Result().success(cmCaseManageService.caseEntrustedList(caseEntrustedParam));
    }

    /**
     * 确认分配案件
     */
    @PostMapping("/caseAssignConfirm")
    @Operation(summary = "确认分配案件")
    public Result<Integer> caseAssignConfirm(@RequestBody CaseAssignConfirmParam caseAssignConfirmParam){
        return new Result().success(cmCaseManageService.caseAssignConfirm(caseAssignConfirmParam));
    }

    /**
     * 确认移交案件
     */
    @GetMapping("/caseTransferConfirm")
    @Operation(summary = "确认移交案件")
    public Result<Integer> caseTransferConfirm(@RequestBody CaseTransferConfirmParam caseTransferConfirmParam){
        return new Result().success(cmCaseManageService.caseTransferConfirm(caseTransferConfirmParam));
    }

    /**
     * 查询案件
     */
    @PostMapping("/caseManage")
    @Operation(summary = "查询案件")
    public Result<CaseManageListVO> caseManage(@RequestBody CaseFindDTO caseFindDTO){
        return new Result().success(cmCaseManageService.caseManageList(caseFindDTO));
    }

    @PostMapping("/lawer")
    @Operation(summary = "查询律师列表")
    public Result<List<CmSysUserVO>> lawer(@RequestBody CaseLawerDTO caseLawerDTO){
        return new Result().success(cmCaseManageService.caseManageLawyerList(caseLawerDTO.getType()));
    }

    @GetMapping("/deposit")
    @Operation(summary = "案件结算状态")
    public Result<List<DepositSettlementStatusVO>> deposit(){
        return new Result().success(cmCaseManageService.caseManageDepositSettlementStatusList());
    }
    @GetMapping("/warning")
    @Operation(summary = "案件预警")
    public Result<List<CmCaseWarningVO>> warning(){
        return new Result().success(cmCaseManageService.caseManageWarningList());
    }
    @GetMapping("/caseState")
    @Operation(summary = "案件阶段")
    public Result<List<Map<String,Long>>> caseState(){
        return new Result().success(cmCaseManageService.caseManageStageCount());
    }

}
